package com.store.service;


import com.common.service.AbstractTypedService;
import com.store.dao.BusinessDao;
import com.store.dao.StoreDao;
import com.store.entities.Business;
import com.store.entities.Store;
import jakarta.annotation.Resource;
import jakarta.transaction.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author fu
 */
@Component
@Transactional
public class BusinessServiceImpl extends AbstractTypedService<Business,Integer> {
    BusinessDao businessDao;
    BusinessServiceImpl(BusinessDao dao){
        this.businessDao =dao;
        this.dataContext=dao;
    }

    public List<Business> pageSearch(Integer pageStart ,Integer pageSize){
        Page<Business> businessPage;
        PageRequest pageRequest=PageRequest.of(pageStart,pageSize, Sort.by("id").ascending());
        try {
                businessPage=businessDao.queryPage(pageRequest,null);
        }catch (Exception e) {
            return null;
        }
        return businessPage.getContent();
        }

}
